package shemes;

import java.awt.Point;
import java.util.ArrayList;

import gui.*;
import components.*;

public class Fetch3 {

    private static OR ORgropr;
    private static OR ORgradr;
    private static AND ANDgradr;
    private static OR ORI1;
    private static OR ORI2_brnch;
    private static AND ANDI2_arlog;
    private static OR ORI2_arlog_1, ORI2_arlog_2;
    private static OR ORI3_jump;
    private static OR ORI3_arlog;
    private static AND ANDI3_arlog;
    private static OR ORstore;
    private static GuiScheme gui;

    public static GuiScheme getGui() {
        return gui;
    }

    public static void init() {

        ORgropr = new OR(10);

        ORgradr = new OR();
        ANDgradr = new AND();

        ORI1 = new OR(12);

        ORI2_brnch = new OR(3);

        ORI2_arlog_1 = new OR(9);
        ORI2_arlog_2 = new OR();
        ANDI2_arlog = new AND();

        ORI3_jump = new OR();

        ANDI3_arlog = new AND();
        ORI3_arlog = new OR(6);

        ORstore = new OR();

    }

    public static void connect() {


        ORgropr.setInputPin(0, Fetch2.G3());
        ORgropr.setInputPin(1, Fetch2.G2());
        ORgropr.setInputPin(2, Fetch2.G1());
        ORgropr.setInputPin(3, Fetch2.G0_PG5_7());
        ORgropr.setInputPin(4, Fetch2.G0_PG5_6());
        ORgropr.setInputPin(5, Fetch2.G0_PG1_7());
        ORgropr.setInputPin(6, Fetch2.G0_PG1_6());
        ORgropr.setInputPin(7, Fetch2.G0_PG1_0());
        ORgropr.setInputPin(8, Fetch2.G0_PG0_3());
        ORgropr.setInputPin(9, Fetch2.G0_PG0_2());

        ORgradr.setInputPin(0, Fetch2.STB());
        ORgradr.setInputPin(1, Fetch2.STW());
        ANDgradr.setInputPin(0, ORgradr.getOut(0));
        ANDgradr.setInputPin(1, Fetch2.imm());

        ORI1.setInputPin(0, Fetch2.G0_PG7());
        ORI1.setInputPin(1, Fetch2.NOT());
        ORI1.setInputPin(2, Fetch2.DEC());
        ORI1.setInputPin(3, Fetch2.INC());
        ORI1.setInputPin(4, Fetch2.G0_PG5());
        ORI1.setInputPin(5, Fetch2.PUSHW());
        ORI1.setInputPin(6, Fetch2.PUSHB());
        ORI1.setInputPin(7, Fetch2.POPW());
        ORI1.setInputPin(8, Fetch2.POPB());
        ORI1.setInputPin(9, Fetch2.RTI());
        ORI1.setInputPin(10, Fetch2.RTS());
        ORI1.setInputPin(11, Fetch2.G0_PG0());

        ORI2_brnch.setInputPin(0, Fetch2.G0_PG3());
        ORI2_brnch.setInputPin(1, Fetch2.G0_PG2());
        ORI2_brnch.setInputPin(2, Fetch2.INT());

        ORI2_arlog_1.setInputPin(0, Fetch2.XOR());
        ORI2_arlog_1.setInputPin(1, Fetch2.OR());
        ORI2_arlog_1.setInputPin(2, Fetch2.AND());
        ORI2_arlog_1.setInputPin(3, Fetch2.SUB());
        ORI2_arlog_1.setInputPin(4, Fetch2.ADD());
        ORI2_arlog_1.setInputPin(5, Fetch2.STW());
        ORI2_arlog_1.setInputPin(6, Fetch2.STB());
        ORI2_arlog_1.setInputPin(7, Fetch2.LDW());
        ORI2_arlog_1.setInputPin(8, Fetch2.LDB());
        ORI2_arlog_2.setInputPin(0, Fetch2.regdir());
        ORI2_arlog_2.setInputPin(1, Fetch2.regind());
        ANDI2_arlog.setInputPin(0, ORI2_arlog_1.getOut(0));
        ANDI2_arlog.setInputPin(1, ORI2_arlog_2.getOut(0));

        ORI3_jump.setInputPin(0, Fetch2.JSR());
        ORI3_jump.setInputPin(1, Fetch2.JMP());

        ORI3_arlog.setInputPin(0, Fetch2.XOR());
        ORI3_arlog.setInputPin(1, Fetch2.OR());
        ORI3_arlog.setInputPin(2, Fetch2.AND());
        ORI3_arlog.setInputPin(3, Fetch2.SUB());
        ORI3_arlog.setInputPin(4, Fetch2.ADD());
        ORI3_arlog.setInputPin(5, Fetch2.LDB());
        ANDI3_arlog.setInputPin(0, ORI3_arlog.getOut(0));
        ANDI3_arlog.setInputPin(1, Fetch2.imm());

        ORstore.setInputPin(0, Fetch2.STB());
        ORstore.setInputPin(1, Fetch2.STW());

    }

    public static void gui() {
        GuiLine line; // Pomocna promenljiva
        gui = new GuiScheme("src/images/Fetch3.png");

        ArrayList<ArrayList<Point>> sections;
        ArrayList<Point> points;



        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 186));
        points.add(new Point(113, 186));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G3());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 201));
        points.add(new Point(113, 201));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 216));
        points.add(new Point(113, 216));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G1());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 231));
        points.add(new Point(113, 231));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG5_7());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 247));
        points.add(new Point(113, 247));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG5_6());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 262));
        points.add(new Point(113, 262));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG1_7());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 277));
        points.add(new Point(113, 277));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG1_6());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 292));
        points.add(new Point(113, 292));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG1_0());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 307));
        points.add(new Point(113, 307));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG0_3());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 322));
        points.add(new Point(113, 322));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG0_2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(137, 254));
        points.add(new Point(144, 254));
        sections.add(points);
        line = new GuiLine(sections, ORgropr.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 243));
        points.add(new Point(294, 243));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.STB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 254));
        points.add(new Point(295, 254));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.STW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(317, 248));
        points.add(new Point(330, 248));
        sections.add(points);
        line = new GuiLine(sections, ORgradr.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 271));
        points.add(new Point(323, 271));
        points.add(new Point(323, 260));
        points.add(new Point(330, 260));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.imm());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(355, 254));
        points.add(new Point(361, 254));
        sections.add(points);
        line = new GuiLine(sections, ANDgradr.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 171));
        points.add(new Point(500, 171));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG7());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 186));
        points.add(new Point(500, 186));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.NOT());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 201));
        points.add(new Point(500, 201));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.DEC());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 216));
        points.add(new Point(500, 216));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.INC());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 231));
        points.add(new Point(500, 231));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG5());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 247));
        points.add(new Point(501, 247));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.PUSHW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 262));
        points.add(new Point(501, 262));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.PUSHB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 277));
        points.add(new Point(500, 277));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.POPW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 292));
        points.add(new Point(500, 292));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.POPB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 307));
        points.add(new Point(500, 307));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.RTI());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 322));
        points.add(new Point(500, 322));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.RTS());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 337));
        points.add(new Point(500, 337));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG0());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(525, 254));
        points.add(new Point(531, 254));
        sections.add(points);
        line = new GuiLine(sections, ORI1.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 379));
        points.add(new Point(113, 379));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG3());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 394));
        points.add(new Point(115, 394));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.G0_PG2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 409));
        points.add(new Point(113, 409));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.INT());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(137, 394));
        points.add(new Point(144, 394));
        sections.add(points);
        line = new GuiLine(sections, ORI2_brnch.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 445));
        points.add(new Point(115, 445));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.JSR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 456));
        points.add(new Point(115, 456));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.JMP());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(137, 451));
        points.add(new Point(144, 451));
        sections.add(points);
        line = new GuiLine(sections, ORI3_jump.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 502));
        points.add(new Point(115, 502));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.STB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(106, 513));
        points.add(new Point(115, 513));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.STW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(137, 508));
        points.add(new Point(144, 508));
        sections.add(points);
        line = new GuiLine(sections, ORstore.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 364));
        points.add(new Point(292, 364));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.XOR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 379));
        points.add(new Point(292, 379));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.OR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 394));
        points.add(new Point(292, 394));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.AND());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 409));
        points.add(new Point(292, 409));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.SUB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 424));
        points.add(new Point(295, 424));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ADD());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 439));
        points.add(new Point(292, 439));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.STW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 455));
        points.add(new Point(292, 455));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.STB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 470));
        points.add(new Point(292, 470));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.LDW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 485));
        points.add(new Point(292, 485));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.LDB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(317, 424));
        points.add(new Point(330, 424));
        sections.add(points);
        line = new GuiLine(sections, ORI2_arlog_1.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 511));
        points.add(new Point(293, 511));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.regdir());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(286, 523));
        points.add(new Point(294, 523));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.regind());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(317, 517));
        points.add(new Point(323, 517));
        points.add(new Point(323, 436));
        points.add(new Point(330, 436));
        sections.add(points);
        line = new GuiLine(sections, ORI2_arlog_2.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(355, 430));
        points.add(new Point(361, 430));
        sections.add(points);
        line = new GuiLine(sections, ANDI2_arlog.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 379));
        points.add(new Point(500, 379));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.XOR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 394));
        points.add(new Point(500, 394));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.OR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 409));
        points.add(new Point(500, 409));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.AND());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 424));
        points.add(new Point(503, 424));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.SUB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 439));
        points.add(new Point(500, 439));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ADD());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 455));
        points.add(new Point(500, 455));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.LDB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(525, 424));
        points.add(new Point(538, 424));
        sections.add(points);
        line = new GuiLine(sections, ORI3_arlog.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 494));
        points.add(new Point(531, 494));
        points.add(new Point(531, 436));
        points.add(new Point(538, 436));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.imm());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(563, 430));
        points.add(new Point(569, 430));
        sections.add(points);
        line = new GuiLine(sections, ANDI3_arlog.getOut(0));
        gui.addLine(line);

    }

    public static Pin gropr() {
        return ORgropr.getOut(0);
    }

    public static Pin gradr() {
        return ANDgradr.getOut(0);
    }

    public static Pin I1() {
        return ORI1.getOut(0);
    }

    public static Pin I2_brnch() {
        return ORI2_brnch.getOut(0);
    }

    public static Pin I2_arlog() {
        return ANDI2_arlog.getOut(0);
    }

    public static Pin I3_jump() {
        return ORI3_jump.getOut(0);
    }

    public static Pin I3_arlog() {
        return ANDI3_arlog.getOut(0);
    }

    public static Pin store() {
        return ORstore.getOut(0);
    }
}
